package info.fitnesse.fixturegallery;

import info.fitnesse.fixturegallery.domain.TaxCalculator;

import java.math.BigDecimal;

import fitnesse.fixtures.TableFixture;

public class TableFixtureTest extends TableFixture{
	protected void doStaticTable(int rows) {
		 TaxCalculator tc=new TaxCalculator();
	      double totaltax = 0;
	      
	      BigDecimal nettotalprice = new BigDecimal("0");	     
	      
	      for (int row = 1; row < rows - 3; row++)
	      {
	        totaltax += tc.GetTax(getText(row, 1), 
	          Double.parseDouble(getText(row, 2)));
	        
	        
	        nettotalprice = nettotalprice.add(BigDecimal.valueOf(tc.GetPrivate(getText(row, 1), 
	        		Double.parseDouble(getText(row, 2)))));
	      }
	      
	      /************ net total **************/
	      double nettotaltable = Double.parseDouble(getText(rows - 3, 2));
	      if (nettotaltable == nettotalprice.doubleValue())
	        right(rows - 3, 2);
	      else
	        wrong(rows - 3, 2,String.valueOf(nettotalprice.doubleValue()));
	      
	      
	      
	      
	      /************ Tax **************/
	      double taxintable = Double.parseDouble(getText(rows - 2, 2));
	      if (taxintable == totaltax)
	        right(rows - 2, 2);
	      else
	        wrong(rows - 2, 2,String.valueOf(totaltax));
	      
	      
	      
	      
	      
	       
	    }
}

